package org.class2table.core.template;

public class SqlTemplate {

    public static class Operation {
        public static final String QUERY_0INFORMATION_SCHEMA0_TEMPLATE
                = "SELECT " +
                "information_schema.COLUMNS.COLUMN_NAME AS columnName, " +
                "information_schema.COLUMNS.COLUMN_TYPE AS dataType, " +
                "information_schema.COLUMNS.COLUMN_DEFAULT AS columnDefault, " +
                "information_schema.COLUMNS.IS_NULLABLE AS isNullable, " +
                "information_schema.COLUMNS.DATA_TYPE AS dataType, " +
                "information_schema.COLUMNS.COLUMN_KEY AS columnKey, " +
                "information_schema.COLUMNS.COLUMN_COMMENT AS columnComment " +
                "FROM " +
                "information_schema.columns " +
                "WHERE " +
                "`TABLE_SCHEMA` = '%s' " +
                "AND `TABLE_NAME` = '%s';";

        public static final String QUERY_0KEY_COLUMN_USAGE0_FOR_PRIMARY_TEMPLATE
                = "SELECT " +
                "information_schema.KEY_COLUMN_USAGE.ORDINAL_POSITION, " +
                "information_schema.KEY_COLUMN_USAGE.COLUMN_NAME " +
                "FROM " +
                "information_schema.KEY_COLUMN_USAGE " +
                "WHERE " +
                "`TABLE_SCHEMA` = '%s' " +
                "AND `TABLE_NAME` = '%s' " +
                "AND `CONSTRAINT_NAME` = 'PRIMARY';";

        public static final String ADD_COLUMN_TEMPLATE
                = "ALTER TABLE `%s` ADD COLUMN `%s` %s %s %s %s;";

        public static final String MODIFY_COLUMN_TEMPLATE
                = "ALTER TABLE `%s` MODIFY COLUMN `%s` %s %s %s %s;";

        public static final String DROP_COLUMN_TEMPLATE
                = "ALTER TABLE `%s` DROP COLUMN `%s`;";

        public static final String CREATE_TABLE_TEMPLATE
                = "CREATE TABLE `%s` (\n" +
                "%s\n" +
                ") ENGINE=InnoDB;";

        public static final String DROP_PRIMARY_KEY_TEMPLATE
                = "ALTER TABLE `%s` DROP PRIMARY KEY;";

        public static final String ADD_PRIMARY_KEY_TEMPLATE
                = "ALTER TABLE `%s` ADD %s USING BTREE;";
    }


    public static class Define {
        public static final String COLUMN_DEFINE_TEMPLATE
                = "`%s` %s %s %s %s";

        public static final String PRIMARY_KEY_DEFINE_TEMPLATE
                = "PRIMARY KEY (%s)";
    }
}
